{% extends 'journal/base.html' %}

{% load editorjs %}

{% block header_title %}
<h1>{{ author.nickname|default:author.username }}的日志列表</h1>
{% endblock header_title %}

{% block main %}
    <div>
        {% if posts %}
            {% for post in posts %}
                <p>
                    <h2>{{ post.title }}</h2>
                    <p>
                        {% if post.published_at %}
                            <span>发布于 {{ post.published_at|date:"Y年m月d日" }}</span>
                        {% endif %}
                    </p>
                    <p>
                        {{ post.content|editorjs|striptags|truncatewords:200 }}
                    </p>
                    <a href="{% url 'post_detail' post.id %}">
                        阅读更多
                    </a>
                </p>
            {% endfor %}
        {% else %}
            <p>该用户暂无日志</p>
        {% endif %}
    </div>
{% endblock %}
